<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/immutable/3.8.2/immutable.min.js"></script>
  <script>
    const im = Immutable

    // Map的使用
    // const info = {
    //   name: 'aa',
    //   age: 20,
    //   friend: {
    //     name: 'bb',
    //     age: 25
    //   }
    // }

    // const infoIM = im.Map(info)

    // const obj = infoIM
    // const infoIM2 = infoIM.set('name', 'why')
    // console.log(obj.get('name'))
    // console.log(infoIM2.get('name'))

    // List的使用
    // const names = ['why','aa', 'bb']
    // // const arr = names
    // // names[0] = 'cc'
    // // console.log(arr)
    // const namesIm = im.List(names)
    // const arr = namesIm.set(0, 'cc')
    // console.log(namesIm.get(0))
    // console.log(arr.get(0))

    const info = {
      name: 'aa',
      age: 20,
      friend: {
        name: 'bb',
        age: 25
      }
    }

    // const infoIm = im.Map(info)
    const infoIm = im.fromJS(info)
    console.log(infoIm.get('friend'))

  </script>
</body>
</html>